﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace s2b_mercado.Account
{
    public partial class Entrar : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            String conexString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["S2B"].ConnectionString;
            System.Data.SqlClient.SqlConnection conexao = new System.Data.SqlClient.SqlConnection(conexString);
            System.Data.SqlClient.SqlCommand comando = new System.Data.SqlClient.SqlCommand();
            comando.Connection = conexao;
            comando.CommandType = System.Data.CommandType.Text;
            comando.CommandText = "SELECT COUNT(*) FROM Usuario WHERE (usu_email = @usuario) AND (usu_senha = @senha)";
            comando.Parameters.AddWithValue("@usuario", txtEmail.Text);
            comando.Parameters.AddWithValue("@senha", txtSenha.Text);
            conexao.Open();
            int i = (int)comando.ExecuteScalar();
            if (i > 0)
                Response.Redirect("minhaConta.aspx?" + "session=" + Session.SessionID);
            else
                Label1.Text = "Usuario ou senha incorretos";
            conexao.Close();
            
        }
 
    }
}